# lz4.cmake
# 本文件包含着从外部导入 lz4 所需要的信息

include(ExternalProject)

set(LZ4_ROOT ${PROJECT_SOURCE_DIR}/extern_module_download/lz4)
set(LZ4_GIT_URL      https://atomgit.com/dangaldb/lz4-Mirror.git)  # 指定git仓库地址
set(LZ4_CONFIGURE    cd ${LZ4_ROOT}/src/extern_lz4/build/cmake && cmake -D CMAKE_INSTALL_PREFIX=${LZ4_ROOT} .)
set(LZ4_MAKE         cd ${LZ4_ROOT}/src/extern_lz4 && make)
set(LZ4_INSTALL      cd ${LZ4_ROOT}/src/extern_lz4/lib && make install prefix=${LZ4_ROOT}/output) 

ExternalProject_Add(extern_lz4
        PREFIX            ${LZ4_ROOT}
        GIT_REPOSITORY    ${LZ4_GIT_URL}
        CONFIGURE_COMMAND ${LZ4_CONFIGURE}
        BUILD_COMMAND     ${LZ4_MAKE}
        INSTALL_COMMAND   ${LZ4_INSTALL}
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/extern_module_download/extern_lz4/output
        -DCMAKE_INSTALL_LIBDIR=${PROJECT_SOURCE_DIR}/extern_module_download/extern_lz4/output
        -DBUILD_TESTING=OFF
        -DBUILD_STATIC_LIBS=ON
        -DBUILD_SHARED_LIBS=OFF
)

INCLUDE_DIRECTORIES(${LZ4_ROOT}/output/include)
LINK_DIRECTORIES(${LZ4_ROOT}/output/lib)